<?php

namespace Drupal\youji_userwxinfo\ViewsController;

use Drupal\youji_userwxinfo\ViewsController\handler\field\YoujiUserwxinfoAvatarViewsField;
use Drupal\youji_userwxinfo\ViewsController\handler\field\YoujiUserwxinfoEditLinkViewsField;
use Drupal\youji_userwxinfo\ViewsController\handler\field\YoujiUserwxinfoSexViewsField;
use Drupal\youji_userwxinfo\ViewsController\handler\filter\YoujiUserwxinfoSexViewsFilter;
use EntityDefaultViewsController;


class YoujiUserwxinfoViewsController extends EntityDefaultViewsController {

  public function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $data[$table]['edit_link'] = [
        'title' => t('编辑'),
        'help' => t('编辑.'),
        'field' => [
          'handler' => YoujiUserwxinfoEditLinkViewsField::class,
        ],
      ];
      $info = [];
      $info[$table]['sex'] = [
        'title' => '性别 0 未知 1 男 2 女',
        'help' => '性别 0 未知 1 男 2 女',
        'real field' => 'sex',
        'field' => [
          'handler' => YoujiUserwxinfoSexViewsField::class,
        ],
        'filter' => [
          'handler' => YoujiUserwxinfoSexViewsFilter::class,
        ],
      ];

      $info[$table]['picture'] = [
        'title' => t('Picture'),
        'help' => t("头像"),
        'field' => [
          'handler' => YoujiUserwxinfoAvatarViewsField::class,
        ],
        'real field' => 'avatar_fid',
      ];

      $data = drupal_array_merge_deep($data, $info);

    }
    return $data;
  }
}
